home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 19 / CU Amiga Magazine's Super CD-ROM 19 (1998)(EMAP Images)(GB)[!][issue 1998-02].iso / CUCD / Online / NNTPd / server / post.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-11-01  |  1.5 KB  |  72 lines

  1. #ifndef lint
  2. static char    sccsid[] = "@(#)$Id: post.c,v 1.19 1994/11/01 06:08:21 sob Exp sob $";
  3. #endif
  4.  
  5. #include "common.h"
  6.  
  7. /*
  8.  * POST
  9.  *
  10.  * Post an article to a set of newsgroups.
  11.  */
  12.  
  13. void
  14. post(argc, argv)
  15.     int    argc;
  16.     char    *argv[];
  17. {
  18.     char    errbuf[2 * NNTP_STRLEN];
  19.     int    retcode;
  20.  
  21.     if (!canpost) {
  22.         printf("%d Sorry, you're not allowed to post.\r\n",
  23.             ERR_NOPOST);
  24. #ifdef LOG
  25.             syslog(LOG_INFO, "%s post rejected", hostname);
  26. #endif
  27.         (void) fflush(stdout);
  28.         return;
  29.     }
  30.  
  31. #ifdef POSTER
  32.     if (uid_poster == 0) {
  33.         printf("%d User %s does not exist!  Can't post.\r\n",
  34.             ERR_POSTFAIL, POSTER);
  35. #ifdef SYSLOG
  36.         syslog(LOG_ERR, "post: User %s does not exist.", POSTER);
  37. #endif
  38.         (void) fflush(stdout);
  39.         return;
  40.     }
  41. #endif
  42.  
  43.     if (!space(MINFREE - POSTBUFFER)) {
  44.         /* force error reporting code into sending */
  45.         /* an out-of-space error message           */
  46.         if (gethostname(errbuf, MAXHOSTNAMELEN) < 0)
  47.         (void) strcpy(errbuf, "Amnesiac");
  48.  
  49.         (void) strcat(errbuf, " NNTP server out of space. Try later.");
  50.  
  51.         retcode = 0;        /* indicates that an error occurred */
  52.     }
  53.     else retcode =
  54. #ifdef CNEWS
  55.         spawn(inews, "inews", "-W", CONT_POST, ERR_POSTFAIL, errbuf,
  56.         "<none>");
  57. #else
  58.         spawn(inews, "inews", "-h", CONT_POST, ERR_POSTFAIL, errbuf,
  59.         "<none>");
  60. #endif
  61.     if (retcode <= 0)
  62.         printf("%d %s\r\n", ERR_POSTFAIL, errbuf);
  63.     else if (retcode > 0)
  64.         printf("%d Article posted successfully.\r\n", OK_POSTED);
  65.     (void) fflush(stdout);
  66.  
  67. #ifdef LOG
  68.     syslog(LOG_INFO, "%s post %s", hostname,
  69.             retcode == 1 ? "succeeded" : "failed");
  70. #endif
  71. }
  72.